package com.dao.impl;

import com.dao.manageMenus;

import static com.util.Vessel.CRUD;

public class manageMenusImpl implements manageMenus {

    //添加菜品
    @Override
    public int addMenu(String mName,double mPrice) {
        int num = 0;
        String sql = "INSERT INTO order_system.menus (mName, mPrice) VALUES (?,?);";
        Object[] objects = new Object[2];
        objects[0] = mName;
        objects[1] = mPrice;
        num = CRUD.update(sql,objects);
        return 0;
    }

    //删除菜品
    @Override
    public int delMenu(int mId) {
        int num = 0;
        String sql = "DELETE FROM menus WHERE mId = ?";
        Object[] objects = new Object[1];
        objects[0] = mId;
        num = CRUD.update(sql,objects);
        return num;
    }

    @Override
    public int alterMenu(int oldmId, int mId, String mName, double mPrice) {
        int num = 0;
        String sql = "UPDATE menus\n" +
                "SET mId = ?,\n" +
                "    mName = ?,\n" +
                "    mPrice = ?\n" +
                "WHERE mId = ?";
        Object[] objects = new Object[4];
        objects[0] = mId;
        objects[1] = mName;
        objects[2] = mPrice;
        objects[3] = oldmId;
        num = CRUD.update(sql,objects);
        return num;
    }

    //更改菜品

}
